package com.kaoshi.myweb.webstruts.controller;

import java.util.Locale;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.LocalizedTextUtil;

public class ConvertAction extends ActionSupport {

	private String msg;
	//jsp中，input框name必须为loc，否则，不会调用自定义转换器
	private Locale loc = Locale.US;
	
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	

	@Override
	public String execute() throws Exception {
		System.out.println("calling execute()");
		msg = LocalizedTextUtil.findDefaultText("HelloWorld", loc);
		return SUCCESS;
	}
	
	
	@Override
	public void validate() {
		System.out.println("calling validate()");
		
		if(!(loc.equals(Locale.US)) ||!(loc.equals(Locale.CHINA)))
		{
			this.addFieldError("loc", getText("validate.loc"));
		}
	}

	public void validateExecute() {
		System.out.println("calling validateExecute()");
	}
	public Locale getLoc() {
		return loc;
	}

	public void setLoc(Locale loc) {
		this.loc = loc;
	}



}
